home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / CDTV / cdtvtools-11 / keeper / prefs.c < prev   
Encoding:
C/C++ Source or Header  |  1991-06-24  |  3.3 KB  |  89 lines

  1. /****************************************************************************
  2. *                                                                           *
  3. * Copyright (c) 1991 Commodore Business Machines, Inc.                      *
  4. * The source code examples included are used on the Welcome Disc.  These    *
  5. * examples are provided for information purposes only, on an "as is" basis. *
  6. * No warranties of any nature, express or implied, are made.  Any use       *
  7. * of these examples is at your own risk with no liability or responsability *
  8. * of any kind being assumed by Commodore, its suppliers and developers,     *
  9. * or their employees.                                                       *
  10. *                                                                           *
  11. * Subject to these limitations, executables based upon these examples       *
  12. * may be developed and used in software for the Commodore CDTV.   All       *
  13. * other rights are reserved.                                                *
  14. *                                                                           *
  15. ****************************************************************************/
  16.  
  17.  
  18. /****************************************************************************
  19.  
  20.   prefs.c -- written by Ray Lambert for Theta Systems, Inc. -- jan-apr 1991
  21.  
  22. ****************************************************************************/
  23.  
  24.  
  25. #include "keeper.h"
  26. #include <exec/io.h>
  27. #include <graphics/gfxbase.h>
  28. #include <graphics/view.h>
  29. #include <proto/exec.h>
  30. #include "cdtvprefs.h"
  31.  
  32. extern struct GfxBase *GfxBase;
  33.  
  34.  
  35. /*
  36. **  This routine attempts to get the CDTV preferences -- if the preferences
  37. **  prove be be elusive for any reason it sets up some sensible defaults.
  38. **  Note that ASL is only concerned with view centering, language selection
  39. **  and audio volume, and therefore generally sets up defaults only for these.
  40. **  We take deafult view centering information from Workbench's view (which
  41. **  is expected to still be active when this routine is called), and set our
  42. **  default language to UNKNOWN.  We set the default audio volume to full
  43. **  volume because the user can always lower the volume on their television
  44. **  or stereo receiver, but if our volume isn't loud enough they may not be
  45. **  capable of raising that volume sufficiently.
  46. */
  47. void ReadPrefs(struct CDTVPrefs *prefs)
  48. {
  49.   unless( BookMarkPrefs(prefs) )
  50.     {
  51.       prefs->DisplayX = GfxBase->ActiView->DxOffset;  /* get view positioning */
  52.       prefs->DisplayY = GfxBase->ActiView->DyOffset;  /* from Intuition view  */
  53.       prefs->AudioVol = 16;
  54.       prefs->Flags    = (CDTVPF_AUDIOVOL|CDTVPF_AMPM);
  55.       prefs->Language = CDTVLANG_UNKNOWN;
  56.     }
  57. }
  58.  
  59.  
  60. /*
  61. **  An example of reading the CDTV preferences...
  62. */
  63. int BookMarkPrefs(struct CDTVPrefs *prefs)
  64. {
  65.   struct IOStdReq *io;
  66.   struct MsgPort  *mp;
  67.   int rc = FALSE;
  68.  
  69. /** try opening 'bookmark.device' **/
  70.   unless( mp = CreatePort(0,0) ) goto fail1;
  71.   unless( io = CreateStdIO(mp) ) goto fail2;
  72.   if (OpenDevice("bookmark.device",BID_CDTVPREFS,io,0)) goto fail3;
  73.  
  74. /** try reading prefs from 'bookmark.device' **/
  75.   io->io_Command = CMD_READ;
  76.   io->io_Data    = (APTR)prefs;
  77.   io->io_Length  = sizeof(*prefs);
  78.   io->io_Offset  = 0;
  79.   if ( (DoIO(io) == 0) && (prefs->Language != CDTVLANG_UNKNOWN) ) rc = TRUE;
  80.   CloseDevice(io);
  81.  
  82. fail3:
  83.   DeleteStdIO(io);
  84. fail2:
  85.   DeletePort(mp);
  86. fail1:
  87.   return(rc);
  88. }
  89.